﻿<cfsilent>
	<cfscript>
	
		sql = "	SELECT
					b.b_id,
					b.b_name,
					c.campus_id,
					b.b_floors,
					c.campus_name
				FROM
					t_building b
					INNER JOIN t_campus c ON b.campus_id = c.campus_id
				WHERE
					b.b_id = :buildingId ";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "buildingId", value = event.getArg("BID"), cfsqltype = "cf_sql_char");
		rs_buildEntity = queryObj.execute( sql = sql ).getResult();

		sql = "	SELECT
					ct.cr_type,ct.cr_type_name
				FROM
					t_classroom_type ct
				ORDER BY
					ct.cr_type ASC";
		
		queryObj = new Query(datasource = application.dnsSlave);
		rs_type = queryObj.execute( sql = sql ).getResult();
		
		sql = "	SELECT
					c.cr_floor,
					COUNT(*) floor_count,
					SUM(c.sits) sum_sits,
					SUM(c.sits_course) sum_sits_course,
					SUM(c.sits_exam) sum_sits_exam
				FROM
					t_classroom c
				WHERE
					c.b_id = :buildingId 
				GROUP BY
					c.cr_floor
				ORDER BY
					c.cr_floor ASC";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "buildingId", value = event.getArg("BID"), cfsqltype = "cf_sql_char");
		rs_floor = queryObj.execute( sql = sql ).getResult();
	
		
		sql = "	SELECT
					rp.purpose_code,rp.purpose
				FROM
					t_room_purpose rp
				WHERE
					   rp.purpose_code LIKE '0_'
					AND
					   rp.purpose_code > '00'
				ORDER BY
					rp.purpose_code ASC";
		
		queryObj = new Query(datasource = application.dnsSlave);
		rs_purpose = queryObj.execute( sql = sql ).getResult();
		
		
		event.setArg("pageTitle", "教学运行基础数据 - 教学场地维护 - 楼宇信息 - " & rs_buildEntity.b_name);
		
		targetArgs = structNew();
		structInsert(targetArgs, "CID", rs_buildEntity.campus_id, true);
		structInsert(targetArgs, "BID", rs_buildEntity.b_id, true);
		
		currentTab = event.getArg("TabID", "labClassroom");
		
		if ( rs_floor.recordCount eq 0 ) {
			currentTab = "labPatchCreate";
		}
		
		showNotice = event.getArg("notice");
		
		/* 分析教学楼的 地上 地下 楼层分布信息 */
		upFloor = 0 + listFirst(rs_buildEntity.b_floors);
		downFloor = 0 + listLast(rs_buildEntity.b_floors);
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		usageAdvice = getProperty("serviceFactory").getBean("classroomUsageAdvice");
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('campusSetting', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText"><cfoutput>#rs_buildEntity.campus_name#</cfoutput>概况</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i><cfoutput>#rs_buildEntity.b_name#</cfoutput>概况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labBaseInfo">class="active"</cfif> id="labBaseInfo" tabTarget="BaseInfo">楼宇信息</span>
						<span <cfif currentTab eq "labClassroom">class="active"</cfif> id="labClassroom" tabTarget="Classroom">教学场地</span>
						<span <cfif currentTab eq "labPatchCreate">class="active"</cfif> id="labPatchCreate" tabTarget="PatchCreate">批量创建教学场地</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="BaseInfo" class="tabContent">
					
					<cfif listFind(showNotice, "buildUpdated")>

							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>楼宇基础数据已更新</h3>
								<p>你可以通过上面的标签切换, 分别查阅到教学场地信息.</p>
							</div>
						
						<cfelse>

							<div class="noticeBlock">
								<h3>更新楼宇信息</h3>
								<p><span class="img icon16x16 message"></span>如果教学楼的可用楼层信息发生变更, 您可以在这里进行相关的数据调整. 只有正确楼层信息, 您才可以在对应的楼层创建教学场地.</p>
								<hr/>
							</div>
						
					</cfif>
					
					<form id="formEdit" onSubmit="javascript:return processVerfiyForm('formEdit');" class="formWrapper" method="post" action="<cfoutput>#buildURL('buildingUpdateDo')#</cfoutput>">
					
						<input type="hidden" name="CampusID" value="<cfoutput>#rs_buildEntity.campus_id#</cfoutput>" />
						<input type="hidden" name="BuildingID" value="<cfoutput>#rs_buildEntity.b_id#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>教学楼</b>
							<input name="BuildingName" id="BuildingName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('BuildingName', rs_buildEntity.b_name)#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>楼层分布</b>
							地上<input name="FloorsUp" id="FloorsUp" type="text" class="typeTinyInt" verification="required" maxlength="2" value="<cfoutput>#upFloor#</cfoutput>" />层,
							地下<input name="FloorsDown" id="FloorsDown" type="text" class="typeTinyInt" verification="required" maxlength="2" value="<cfoutput>#downFloor#</cfoutput>" />层
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="更新" />
							<input class="button" type="reset" value="重设表格" />
						</div>
					
					</form>
					
					<div class="systemNotice">
						<h3><span class="img icon16x16 info"></span>删除楼宇信息</h3>
						<p>注意: 删除一个楼宇信息的同时, 会同时删除该楼宇内的教学场地设置信息. </p>
						<p>如果您确定<cfoutput>#rs_buildEntity.b_name#</cfoutput>在当前的教学安排中未使用, 并且在以后都不再使用这个建筑的所有教学场地, 您可以在这里进行信息删除. 如果这些教学场地还安排有相关教学任务, 由于数据完整性维护的强制性要求, 这些相关信息会被同样删除. </p>
					
						<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('buildingRemoveDo')#</cfoutput>">
							<input type="hidden" name="CampusID" value="<cfoutput>#rs_buildEntity.campus_id#</cfoutput>" />
							<input type="hidden" name="BuildingID" value="<cfoutput>#rs_buildEntity.b_id#</cfoutput>" />
							<div class="lable"><input class="button2" type="submit" value="删除建筑" /></div>
						</form>
					</div>
				
				</div>
				
				<div id="Classroom" class="tabContent">
				
					<cfif rs_floor.recordCount>
						<cfset arrayidx = 0 />
						<div id="clsroomTables">
                            <cfloop query="rs_floor">
								<cfset arrayidx++/>
								
								<div class="noticeBlock">
									<cfif arrayidx eq 1>
									<div class="operation">
										<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('classroomDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载教室数据</span></a>
									</div>
									</cfif>
									<h3><cfoutput>#dictAdvice.getFloorString(rs_floor.cr_floor)#</cfoutput></h3>
									<p><span class="img icon16x16 message"></span>共计<cfoutput>#rs_floor.floor_count#</cfoutput>个教室, 实际座位数<cfoutput>#rs_floor.sum_sits#</cfoutput>, 最多可容纳<cfoutput>#rs_floor.sum_sits_course#</cfoutput>人同时上课, 考场座次合计<cfoutput>#rs_floor.sum_sits_exam#</cfoutput>个.</p>
									<hr/>
								</div>
								
								<cfset sql = "	SELECT
													c.cr_usage,
													c.cr_id,
													c.classroom,
													c.sits,
													c.sits_course,
													c.sits_exam,
													ct.cr_type_name,
													ct.cr_type
												FROM
													t_classroom c
													INNER JOIN t_classroom_type ct ON c.cr_type = ct.cr_type
												WHERE
													c.b_id = :buildingId 
													AND
													c.cr_floor = :floor 
												ORDER BY
													c.classroom ASC" />
								
                                <cfset queryObj = new Query(datasource = application.dnsSlave)/>
                                <cfset queryObj.addParam(name = "buildingId", value = rs_buildEntity.b_id, cfsqltype = "cf_sql_char") />
                                <cfset queryObj.addParam(name = "floor", value = rs_floor.cr_floor, cfsqltype = "cf_sql_char") />
                                <cfset rs_clsroom = queryObj.execute(sql = sql).getResult()/>
                               
                                
								<cfset row = 0 />
								<table class="UIEditable">
									<thead>
										<tr>
											<td width="18"></td>
											<td>教室</td>
											<td width="60" align="center">座位数</td>
											<td width="60" align="center">上课</td>
											<td width="60" align="center">考试</td>
											<td width="120">教室类别</td>
											<td width="24">状态</td>
											<td width="24">排课</td>
											<td width="24">考试</td>
											<td width="24">借用</td>
											<td width="36">自习室</td>
											<td width="18"></td>
										</tr>
									</thead>
									<tbody>
									<cfloop query="rs_clsroom">
										<cfset usageAdvice.parseUsage( rs_clsroom.cr_usage ) />
										
										<cfset row++ />
										<tr class="editRows" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>">
											<td>
												<div class="deactive index forDelete">
													<cfoutput>#numberFormat(row, '0_')#</cfoutput>
												</div>
												<div class="active forDelete">
													<a href="javascript:void(0);" class="stat delete" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
												</div>
											</td>
											<td>
												<div class="deactive" forField="Name"><cfoutput>#rs_clsroom.classroom#</cfoutput></div>
												<div class="active" forField="Name">
													<input style="width:120px;" forField="Name" class="activeTextAuto" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>" type="text" value="<cfoutput>#rs_clsroom.classroom#</cfoutput>" />
												</div>
											</td>
											<td align="center">
												<div class="deactive" forField="SitCount"><cfoutput>#rs_clsroom.sits#</cfoutput></div>
												<div class="active" forField="SitCount">
													<input style="width:40px;" forField="SitCount" class="activeTextAuto" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>" type="text" maxlength="3" value="<cfoutput>#rs_clsroom.sits#</cfoutput>" />
												</div>
											</td>
											<td align="center">
												<div class="deactive" forField="SitForCourse"><cfoutput>#rs_clsroom.sits_course#</cfoutput></div>
												<div class="active" forField="SitForCourse">
													<input style="width:40px;" forField="SitForCourse" class="activeTextAuto" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>" type="text" maxlength="3" value="<cfoutput>#rs_clsroom.sits_course#</cfoutput>" />
												</div>
											</td>
											<td align="center">
												<div class="deactive" forField="SitForExam"><cfoutput>#rs_clsroom.sits_exam#</cfoutput></div>
												<div class="active" forField="SitForExam">
													<input style="width:40px;" forField="SitForExam" class="activeTextAuto" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>" type="text" maxlength="3" value="<cfoutput>#rs_clsroom.sits_exam#</cfoutput>" />
												</div>
											</td>
											<td>
												<div class="deactive" forField="ClassroomType"><cfoutput>#rs_clsroom.cr_type_name#</cfoutput></div>
												<div class="active" forField="ClassroomType">
													<select forField="ClassroomType" class="activeSelectAuto" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>">
                                                        <cfloop query="rs_type">
															<option <cfif rs_clsroom.cr_type eq rs_type.cr_type>selected="selected"</cfif> value="<cfoutput>#rs_type.cr_type#</cfoutput>"><cfoutput>#rs_type.cr_type_name#</cfoutput></option>
														</cfloop>
													</select>
												</div>
											</td>
											<td>
												<cfif usageAdvice.getRunning()>
													<a href="javascript:void(0);" class="stat yes" usage="Running" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
													<cfelse>
													<a href="javascript:void(0);" class="stat no" usage="Running" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
												</cfif>
											</td>
											<td>
												<cfif usageAdvice.getForCourse()>
													<a href="javascript:void(0);" class="stat yes" usage="ForCourse" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
													<cfelse>
													<a href="javascript:void(0);" class="stat no" usage="ForCourse" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
												</cfif>
											</td>
											<td>
												<cfif usageAdvice.getForExam()>
													<a href="javascript:void(0);" class="stat yes" usage="ForExam" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
													<cfelse>
													<a href="javascript:void(0);" class="stat no" usage="ForExam" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
												</cfif>
											</td>
											<td>
												<cfif usageAdvice.getForBorrow()>
													<a href="javascript:void(0);" class="stat yes" usage="ForBorrow" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
													<cfelse>
													<a href="javascript:void(0);" class="stat no" usage="ForBorrow" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
												</cfif>
											</td>
											<td>
												<cfif usageAdvice.getForStudy()>
													<a href="javascript:void(0);" class="stat yes" usage="ForStudy" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
													<cfelse>
													<a href="javascript:void(0);" class="stat no" usage="ForStudy" rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>"></a>
												</cfif>
											</td>
											<td>
												<span rowid="<cfoutput>#rs_clsroom.cr_id#</cfoutput>" class="stat saved"></span>
											</td>
										</tr>
									</cfloop>
									</tbody>
								</table>
								
							</cfloop>
						</div>
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$("div#clsroomTables").ready(function() {
									
									var $div = $(this);
									
									$("tr.editRows", $div).dblclick(function(e) {
										
										var rowid = $(this).attr("rowid");
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
										
										$("div.deactive", $row).hide("fast", function(){
											$("div.active", $row).show("fast");
										});
										
										$("span.stat", $row).removeClass("saved").addClass("save");
										
									});
									
									/* form element blur reset */
									$("span.stat", ".UIEditable tr.editRows").click(function(){
											
										var rowid = $(this).attr("rowid");
										var $row = $("tr.editRows[rowid='" + rowid + "']", ".UIEditable");
							
										$("span.stat", $row).removeClass("waiting").removeClass("save").removeClass("checked").addClass("saved");
										
										$("div.active", $row).hide("fast", function(){
											$("div.deactive", $row).show("fast");
										});
											
									});
									
									/* form element trigger */
									$("select[forField]", $div).change(function(e) {
										
										var $input = $(this);
										var rowid = $input.attr("rowid");
										var field = $input.attr("forField");
										
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
										
										var fieldClassroomType = $(":input[forField='ClassroomType']", $row).val();
										
										$.post(
												"<cfoutput>#buildURL('apiClassroomUpdate')#</cfoutput>", 
												{
													'crid' : rowid,
													'ClassroomType' : fieldClassroomType,
													'seed': (new Date()).getTime()
												},
												function(data) {
													
													result = $.parseJSON(data);
													
													var rowid = result.classroom.ClassroomID;
													var $row = $("tr.editRows[rowid='" + rowid + "']", $div);

													$("div[forField='ClassroomType'].deactive", $row).text(result.ClassroomType.TypeName);
													
												});
										
										$("div[forField=" + field + "].active", $row).hide("fast", function(){
											$("div[forField=" + field + "].deactive", $row).show("fast");
										});
																				
									});
									
									$("input[forField]", $div).blur(function(e) {
										
										var $input = $(this);
										var rowid = $input.attr("rowid");
										var field = $input.attr("forField");
										
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
										
										var valueWas = $("div[forField=" + field + "].deactive", $row).text();
										
										/* 字段内容发生更新 */
										if (valueWas != $input.val()) {
											
											var fieldName = $(":input[forField='Name']", $row).val();
											var fieldSitCount = $(":input[forField='SitCount']", $row).val();
											var fieldSitForCourse = $(":input[forField='SitForCourse']", $row).val();
											var fieldSitForExam = $(":input[forField='SitForExam']", $row).val();
											
											$.post(
												"<cfoutput>#buildURL('apiClassroomUpdate')#</cfoutput>", 
												{
													'crid' : rowid,
													'Name' : fieldName,
													'SitCount' : fieldSitCount,
													'SitForCourse' : fieldSitForCourse,
													'SitForExam' : fieldSitForExam,
													'seed': (new Date()).getTime()
												}, 
												function(data) {
													
													result = $.parseJSON(data);
													
														
													var rowid = result.classroom.ClassroomID;
													var $row = $("tr.editRows[rowid='" + rowid + "']", $div);

													$("div[forField='Name'].deactive", $row).text(result.classroom.Name);
													
													$("div[forField='SitCount'].deactive", $row).text(result.classroom.SitCount);
													$("div[forField='SitForCourse'].deactive", $row).text(result.classroom.SitForCourse);
													$("div[forField='SitForExam'].deactive", $row).text(result.classroom.SitForExam);
													
													
													
												});
											
											
											
										}

										$("div[forField=" + field + "].active", $row).hide("fast", function(){
											$("div[forField=" + field + "].deactive", $row).show("fast");
										});
										
									});
									
									/* form delete trigger */
									$("a.delete", $div).click(function(){
											
										var rowid = $(this).attr("rowid");
											
										$.post(
												"<cfoutput>#buildURL('apiClassroomDelete')#</cfoutput>", 
												{
													'crid' : rowid,
													'seed': (new Date()).getTime()
												}, 
												function(data) {
														
													result = $.parseJSON(data);
														
													var rowid = result.ClassroomID;
													var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
														
													$row.hide();
												});
									});
									
									/* classroom usage trigger */
									$("a[usage]", $div).click(function(){

										var rowid = $(this).attr("rowid");
										var method = $(this).attr("usage");

										var status = $(this).hasClass("yes");

										var newStatus = true;

										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);

										/* 切换状态数据 */
										if (status) {
											newStatus = false;
										}

										/* 发送请求 */
										$(this).removeClass("no").removeClass("yes").addClass("waiting");

										$.post(
												"<cfoutput>#buildURL('apiClassroomUsageChange')#</cfoutput>", 
												{
													'crid' : rowid,
													'prop' : method,
													'status' : newStatus,
													'seed': (new Date()).getTime()
												}, 
												function(data) {

													result = $.parseJSON(data);

													$(this).removeClass("waiting");

													/* 刷新教室状态数据 */
													if (result.Running) { $("a[usage='Running']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='Running']", $row).removeClass("yes").addClass("no"); }

													if (result.ForCourse) { $("a[usage='ForCourse']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='ForCourse']", $row).removeClass("yes").addClass("no"); }
													if (result.ForExam) { $("a[usage='ForExam']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='ForExam']", $row).removeClass("yes").addClass("no"); }
													if (result.ForBorrow) { $("a[usage='ForBorrow']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='ForBorrow']", $row).removeClass("yes").addClass("no"); }
													if (result.ForStudy) { $("a[usage='ForStudy']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='ForStudy']", $row).removeClass("yes").addClass("no"); }
													
													
												});
										
									});
									
								});
								// -->
								//]]>
							</script>
							
							
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>尚未设置教学场地</h3>
								<p>当前您还没有设置<cfoutput>#rs_buildEntity.b_name#</cfoutput>的教学场地, 请通过上方的 "批量创建教学场地" 标签快速的添加多个相同座位数的教室.</p>
							</div>
					</cfif>
				
				</div>
				
				
				
				<div id="PatchCreate" class="tabContent">
					
					<div class="noticeBlock">
						<h3>批量创建教室</h3>
						<p><span class="img icon16x16 message"></span>通常来说, 一个教学楼的教室大小会分为几个不同的规格, 相同规格的教室有多个. 并且这些教室在编号时会按照一定的规律进行. 在这种情况下您可以使用我们提供的工具快速的创建教室信息.</p>
						<hr/>
					</div>
					
					<form id="formBatch" onSubmit="javascript:return processVerfiyForm('formBatch');" class="formWrapper" method="post" action="<cfoutput>#buildURL('classroomBatchCreateDo')#</cfoutput>">
						
						<input type="hidden" name="BuildingID" value="<cfoutput>#rs_buildEntity.b_id#</cfoutput>" />

						<div class="label">
							<b>教室命名规则</b>
							<input name="tarBuilding" id="tarBuilding" type="text" class="typeTinyText" verification="required" maxlength="6" value="<cfoutput>#left(rs_buildEntity.b_name, 2)#</cfoutput>" />
							+ 
							所在楼层
							+
							<input name="tarIdx" id="tarIdx" type="text" class="typeTinyInt" verification="required" maxlength="1" value="2" />
							位流水号
						</div>
						
						<div class="label">
							<b>所在楼层</b>
							<select name="Floor" id="Floor">
								<cfloop from="1" to="#upFloor#" index="step">
									<option value="<cfoutput>#step#</cfoutput>">第<cfoutput>#step#</cfoutput>楼</option>
								</cfloop>
								<cfif downFloor gt 0>
									<cfloop from="1" to="#downFloor#" index="step">
										<option value="<cfoutput>B#step#</cfoutput>">地下<cfoutput>#step#</cfoutput>层</option>
									</cfloop>
								</cfif>
							</select>
						</div>
						
						<div class="label">
							<b>教室数量</b>
							<input name="tarCount" id="tarCount" type="text" class="typeTinyInt" verification="required" maxlength="2" value="10" />
						</div>
						
						<hr/>
						
						<div id="Preview" class="label hidden_elem">
							<div class="secondRow">
								<div class="systemNotice">
									<p>注意: 这里生成的流水号是教学场地批量命名形式示意, 实际的教室水流编号将自动根据已保存的教室信息自动递增.</p>
									<p id="genPreview"><!--.--></p>
								</div>
							</div>

							
							<div style="margin:10px 0;">
								<input class="button" type="submit" value="批量生成场地信息" />
							</div>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>座位数</b>
							实际容量<input name="SitCount" id="SitCount" type="text" class="typeTinyInt" verification="integer" maxlength="3" value="30" />
							上课人数<input name="SitForCourse" id="SitForCourse" type="text" class="typeTinyInt" verification="integer" maxlength="3" value="30" />
							考试人数<input name="SitForExam" id="SitForExam" type="text" class="typeTinyInt" verification="integer" maxlength="3" value="30" />
						</div>
						
						<div class="label">
							<b>教室用途</b>
							<input name="Running" id="Running" type="checkbox" checked="checked" class="typeCheckbox" value="1" />正常使用
							<div class="secondRow">
								<input name="ForCourse" id="ForCourse" type="checkbox" checked="checked" class="typeCheckbox" value="1" />上课
								<input name="ForExam" id="ForExam" type="checkbox" checked="checked" class="typeCheckbox" value="1" />考试
								<input name="ForBorrow" id="ForBorrow" type="checkbox" checked="checked" class="typeCheckbox" value="1" />临时借用
								<input name="ForStudy" id="ForStudy" type="checkbox" checked="checked" class="typeCheckbox" value="1" />自习
							</div>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>教学场地类别</b>
							<select name="ClassroomPurpose" id="ClassroomPurpose">
                                <cfloop query="rs_purpose">
									<option value="<cfoutput>#rs_purpose.purpose_code#</cfoutput>"><cfoutput>#rs_purpose.purpose#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<div class="label">
							<b>教室类型</b>
							<select name="ClassroomType" id="ClassroomType">
								<cfloop query="rs_type">
									<option value="<cfoutput>#rs_type.cr_type#</cfoutput>"><cfoutput>#rs_type.cr_type_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>

						<hr/>
						
						<div class="lable">
							<input id="btnPreview" class="button" type="button" value="预览" />
							<input class="button" type="reset" value="重设表格" />
						</div>
						
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$("form#formBatch").ready(function() {
							
							function crGen() {
								
								$("p#genPreview", $form).html("重新计算");
								
								var count = parseInt( trim( $("input#tarCount", $form).val() ) );
								var n = parseInt( trim( $("input#tarIdx", $form).val() ) );
								
								if (len(count) <= n) {
									
									var build = trim( $("input#tarBuilding", $form).val() );
									var fl = $("select#Floor", $form).val();
																
									var result = [];
					
									for (var i=1; i <= count; i++) {
									
										var idx = Array(n).join('0') + i;
										var crname = build + fl + right(idx, n);
										
										if (i > 3 && i < (count-2) ) {
											crname = "";
										}
										else {
											crname = crname + ', ';
										}
										
										if (count > 6 && i == (count-3)) crname = ".......... ";
										if (i == count) crname = build + fl + right(idx, n);

										
										result = result + crname;
									}
								
									$("p#genPreview", $form).html(result.toString());
									
									if (processVerfiyForm('formBatch')) {
										$("div#Preview").removeClass("hidden_elem");
									}

									
								}
								else {
									alert("流水号长度小于教室数量");
								}
								
							}
							
							/* init Batch */
							var $form = $("form#formBatch");
														
							$("input#Running", $form).change(function(){
								
								if ($(this).prop('checked')) {
									$("input:checkbox", $form).prop("checked", true);;
								}
								else {
									$("input:checkbox", $form).removeAttr('checked');
								}
								
							});
							
							$("select#ClassroomPurpose", $form).change(function(){
								
								if ($(this).val() != '01') {
									$("select#ClassroomType", $form).val('9');
								}
								else {
									$("select#ClassroomType", $form).val('1');
								}
								
							});
							
							$("input#btnPreview", $form).click(function(){
								crGen();
							});
							
						});
						// -->
						//]]>
					</script>
					
					
				</div>
				
			</div>
		</li>
	</ul>
</div>